﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using Landscape.Business.Entities;

namespace Landscape.Business.FNH.Activities
{
    public class OperationsActivities : BusinessActivities
    {
        public OperationsActivities()
            : base()
        { }

        public OperationsActivities(ISession pSession)
            : base(pSession)
        { }

        public Entities.Action GetCorrectiveActionByID(Guid pCARID)
        {
            return CurrentSession.Get<Entities.Action>(pCARID);
        }

        public Guid SaveAction(Entities.Action correctiveAction)
        {
            this.SaveEntity<Entities.Action>(correctiveAction);
            var criteria = CurrentSession.CreateCriteria<Entities.Action>();
            var items = criteria.List<Entities.Action>().Where(exp => exp.Title == correctiveAction.Title);
            return criteria.List<Entities.Action>().Where(exp => exp.Title == correctiveAction.Title && exp.CreatedDate == correctiveAction.CreatedDate).Single().ID;
        }
    }
}
